package finalProject;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;


public class NounPair implements WritableComparable<NounPair>{

	private String NPx, NPy;
	
	public NounPair() {
		this.NPx = "";
		this.NPy = "";
	}
	
	public NounPair(String NPx, String NPy) {
		this.NPx = NPx.toLowerCase();
		this.NPy = NPy.toLowerCase();
	}

	public NounPair(NounPair nounPair) {
		this.NPx = nounPair.getNPx();
		this.NPy = nounPair.getNPy();
	}

	public String getNPx() {
		return NPx;
	}

	public String getNPy() {
		return NPy;
	}

	@Override
	public void readFields(DataInput input) throws IOException {
		String[] in = input.readUTF().split("\t");
		this.NPx = in[0];
		this.NPy = in[1];
	}

	@Override
	public void write(DataOutput out) throws IOException {
		out.writeUTF(this.NPx + "\t" + this.NPy);
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof NounPair)
		{
			NounPair other = (NounPair)obj;
			return this.NPx.equals(other.getNPx()) && this.NPy.equals(other.getNPy());
		}
		return false;
	}

	@Override
	public int compareTo(NounPair other) {
		int ans = 0;
		ans = this.NPx.compareTo(other.getNPx());
		if(ans == 0)
		{
			ans = this.NPy.compareTo(other.getNPy());
		}
		return ans;
	}

	@Override
	public String toString() {
		return NPx+" "+NPy;
	}

	@Override
	public int hashCode() {
		return this.toString().hashCode();
	}
	
	
	
}
